/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dyniablaster.graphics;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.IOException;
import java.util.Vector;

/**
 * @author Damian2
 */
public class DyniaBlasterDesign {

    //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
    private TiledLayer explosion;
    private Image dyniaBomb;
    private Image postacie2;
    private TiledLayer level1;
    private Image fire_central;
    private Sprite playerSprite;
    public int walkLeftDelay = 200;
    public int[] walkLeft = {1, 29, 1, 57};
    public int walkRightDelay = 200;
    public int[] walkRight = {3, 31, 3, 59};
    public int walkDownDelay = 200;
    public int[] walkDown = {0, 28, 0, 56};
    public int walkUpDelay = 200;
    public int[] walkUp = {2, 30, 2, 58};
    private Image platform_tiles;
    private Sprite bomby;
    public int bombyseq001Delay = 200;
    public int[] bombyseq001 = {0, 0, 0, 0};
    public int boomDelay = 200;
    public int[] boom = {1, 1, 1, 1};
    private Sprite player;
    public int up1Delay = 180;
    public int[] up1 = {2, 17, 2, 32};
    public int dieDelay = 180;
    public int[] die = {19, 20, 21, 34, 35, 36};
    public int downDelay = 180;
    public int[] down = {0, 15, 0, 30};
    public int leftDelay = 180;
    public int[] left = {1, 16, 1, 31};
    public int rightDelay = 180;
    public int[] right = {3, 18, 3, 33};
    private Sprite player1;
    public int goLeftDelay = 200;
    public int[] goLeft = {100, 101, 102, 103};
    public int goUpDelay = 200;
    public int[] goUp = {96, 95, 96, 97};
    public int goDownDelay = 200;
    public int[] goDown = {88, 89, 90, 91};
    private Image postacie_16x16;
    private Image bomb;
    private TiledLayer floor;
    private Image topview_tiles;
    private TiledLayer labirynt;
    private Sprite enemy;
    public int enemyseq001Delay = 200;
    public int[] enemyseq001 = {116, 117, 118, 117};
    //</editor-fold>//GEN-END:|fields|0|
    private Vector bombs;
    static int bombsCount = 5;
    //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
    //</editor-fold>//GEN-END:|methods|0|

    public void updateLayerManagerForScena(LayerManager lm) throws java.io.IOException {//GEN-LINE:|1-updateLayerManager|0|1-preUpdate
        // write pre-update user code here
        bombs = new Vector();
        /*getPlayer().setPosition(111, 175);
        getPlayer().setVisible(false);
        lm.append(getPlayer());*/

        getPlayer1().setPosition(111, 175);
        getPlayer1().setVisible(true);
        lm.append(getPlayer1());

        getEnemy().setPosition(80, 175);
        getEnemy().setVisible(true);
        lm.append(getEnemy());

        /*getPlayerSprite().setPosition(111, 175);
        getPlayerSprite().setVisible(true);
        lm.append(getPlayerSprite());*/

        setDynia2();
        for(int i=0; i<bombsCount; i++)
            lm.append((Sprite)bombs.elementAt(i));

        getLabirynt().setPosition(0, 0);
        getLabirynt().setVisible(true);
        lm.append(getLabirynt());

        getExplosion().setVisible(false);
        lm.append(getExplosion());

        getLevel1().setPosition(16, 16);//GEN-BEGIN:|1-updateLayerManager|1|1-postUpdate
        getLevel1().setVisible(true);
        lm.append(getLevel1());
        getFloor().setPosition(0, 0);
        getFloor().setVisible(true);
        lm.append(getFloor());//GEN-END:|1-updateLayerManager|1|1-postUpdate
        // write post-update user code here


    }//GEN-BEGIN:|1-updateLayerManager|2|
//GEN-END:|1-updateLayerManager|2|

    public Image getTopview_tiles() throws java.io.IOException {//GEN-BEGIN:|2-getter|0|2-preInit
        if (topview_tiles == null) {//GEN-END:|2-getter|0|2-preInit
            // write pre-init user code here
            topview_tiles = Image.createImage("/topview_tiles.png");//GEN-BEGIN:|2-getter|1|2-postInit
        }//GEN-END:|2-getter|1|2-postInit
        // write post-init user code here
        return this.topview_tiles;//GEN-BEGIN:|2-getter|2|
    }
//GEN-END:|2-getter|2|

    public TiledLayer getFloor() throws java.io.IOException {//GEN-BEGIN:|3-getter|0|3-preInit
        if (floor == null) {//GEN-END:|3-getter|0|3-preInit
            // write pre-init user code here
            floor = new TiledLayer(20, 22, getTopview_tiles(), 16, 16);//GEN-BEGIN:|3-getter|1|3-midInit
            int[][] tiles = {
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
            };//GEN-END:|3-getter|1|3-midInit
            // write mid-init user code here
            for (int row = 0; row < 22; row++) {//GEN-BEGIN:|3-getter|2|3-postInit
                for (int col = 0; col < 20; col++) {
                    floor.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|3-getter|2|3-postInit
        // write post-init user code here
        return floor;//GEN-BEGIN:|3-getter|3|
    }
//GEN-END:|3-getter|3|

    public Image getPlatform_tiles() throws java.io.IOException {//GEN-BEGIN:|4-getter|0|4-preInit
        if (platform_tiles == null) {//GEN-END:|4-getter|0|4-preInit
            // write pre-init user code here
            platform_tiles = Image.createImage("/platform_tiles.png");//GEN-BEGIN:|4-getter|1|4-postInit
        }//GEN-END:|4-getter|1|4-postInit
        // write post-init user code here
        return this.platform_tiles;//GEN-BEGIN:|4-getter|2|
    }
//GEN-END:|4-getter|2|

    public TiledLayer getLabirynt() throws java.io.IOException {//GEN-BEGIN:|5-getter|0|5-preInit
        if (labirynt == null) {//GEN-END:|5-getter|0|5-preInit
            // write pre-init user code here
            labirynt = new TiledLayer(24, 21, getPlatform_tiles(), 16, 16);//GEN-BEGIN:|5-getter|1|5-midInit
            int[][] tiles = {
                { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0 },
                { 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0 }
            };//GEN-END:|5-getter|1|5-midInit
            // write mid-init user code here
            for (int row = 0; row < 21; row++) {//GEN-BEGIN:|5-getter|2|5-postInit
                for (int col = 0; col < 24; col++) {
                    labirynt.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|5-getter|2|5-postInit
        // write post-init user code here
        return labirynt;//GEN-BEGIN:|5-getter|3|
    }
//GEN-END:|5-getter|3|

    public Image getPostacie2() throws java.io.IOException {//GEN-BEGIN:|33-getter|0|33-preInit
        if (postacie2 == null) {//GEN-END:|33-getter|0|33-preInit
            // write pre-init user code here
            postacie2 = Image.createImage("/postacie2.png");//GEN-BEGIN:|33-getter|1|33-postInit
        }//GEN-END:|33-getter|1|33-postInit
        // write post-init user code here
        return this.postacie2;//GEN-BEGIN:|33-getter|2|
    }
//GEN-END:|33-getter|2|



    public Sprite getPlayer() throws java.io.IOException {//GEN-BEGIN:|36-getter|0|36-preInit
        if (player == null) {//GEN-END:|36-getter|0|36-preInit
            // write pre-init user code here
            player = new Sprite(getPostacie2(), 16, 23);//GEN-BEGIN:|36-getter|1|36-postInit
            player.setFrameSequence(right);//GEN-END:|36-getter|1|36-postInit
            // write post-init user code here
        }//GEN-BEGIN:|36-getter|2|
        return player;
    }
//GEN-END:|36-getter|2|

    public Sprite getPlayer1() throws java.io.IOException {//GEN-BEGIN:|55-getter|0|55-preInit
        if (player1 == null) {//GEN-END:|55-getter|0|55-preInit
            // write pre-init user code here
            player1 = new Sprite(getTopview_tiles(), 16, 16);//GEN-BEGIN:|55-getter|1|55-postInit
            player1.setFrameSequence(goDown);//GEN-END:|55-getter|1|55-postInit
            // write post-init user code here
        }//GEN-BEGIN:|55-getter|2|
        return player1;
    }
//GEN-END:|55-getter|2|

    public Image getDyniaBomb() throws java.io.IOException {//GEN-BEGIN:|59-getter|0|59-preInit
        if (dyniaBomb == null) {//GEN-END:|59-getter|0|59-preInit
            // write pre-init user code here
            dyniaBomb = Image.createImage("/dyniaBomb.png");//GEN-BEGIN:|59-getter|1|59-postInit
        }//GEN-END:|59-getter|1|59-postInit
        // write post-init user code here
        return this.dyniaBomb;//GEN-BEGIN:|59-getter|2|
    }
//GEN-END:|59-getter|2|



    public Image getFire_central() throws java.io.IOException {//GEN-BEGIN:|142-getter|0|142-preInit
        if (fire_central == null) {//GEN-END:|142-getter|0|142-preInit
            // write pre-init user code here
            fire_central = Image.createImage("/fire_central.png");//GEN-BEGIN:|142-getter|1|142-postInit
        }//GEN-END:|142-getter|1|142-postInit
        // write post-init user code here
        return this.fire_central;//GEN-BEGIN:|142-getter|2|
    }
//GEN-END:|142-getter|2|



    public Image getBomb() throws java.io.IOException {//GEN-BEGIN:|145-getter|0|145-preInit
        if (bomb == null) {//GEN-END:|145-getter|0|145-preInit
            // write pre-init user code here
            bomb = Image.createImage("/bomb.png");//GEN-BEGIN:|145-getter|1|145-postInit
        }//GEN-END:|145-getter|1|145-postInit
        // write post-init user code here
        return this.bomb;//GEN-BEGIN:|145-getter|2|
    }
//GEN-END:|145-getter|2|

    public Sprite getBomby() throws java.io.IOException {//GEN-BEGIN:|146-getter|0|146-preInit
        if (bomby == null) {//GEN-END:|146-getter|0|146-preInit
            // write pre-init user code here
            bomby = new Sprite(getBomb(), 16, 16);//GEN-BEGIN:|146-getter|1|146-postInit
            bomby.setFrameSequence(bombyseq001);//GEN-END:|146-getter|1|146-postInit
            // write post-init user code here
        }//GEN-BEGIN:|146-getter|2|
        return bomby;
    }
//GEN-END:|146-getter|2|

    public TiledLayer getExplosion() throws java.io.IOException {//GEN-BEGIN:|177-getter|0|177-preInit
        if (explosion == null) {//GEN-END:|177-getter|0|177-preInit
            // write pre-init user code here
            explosion = new TiledLayer(20, 20, getBomb(), 16, 16);//GEN-BEGIN:|177-getter|1|177-midInit
            int[][] tiles = {
                { 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 3, 3, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
            };//GEN-END:|177-getter|1|177-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|177-getter|2|177-postInit
                for (int col = 0; col < 20; col++) {
                    explosion.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|177-getter|2|177-postInit
        // write post-init user code here
        return explosion;//GEN-BEGIN:|177-getter|3|
    }
//GEN-END:|177-getter|3|

    public TiledLayer getLevel1() throws java.io.IOException {//GEN-BEGIN:|179-getter|0|179-preInit
        if (level1 == null) {//GEN-END:|179-getter|0|179-preInit
            // write pre-init user code here
            level1 = new TiledLayer(20, 20, getPlatform_tiles(), 16, 16);//GEN-BEGIN:|179-getter|1|179-midInit
            int[][] tiles = {
                { 12, 0, 0, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0 },
                { 0, 12, 0, 0, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 0, 0, 0 },
                { 0, 0, 12, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0 },
                { 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0 },
                { 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 12, 12, 12, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 12, 0, 0, 0, 12, 0, 12, 0, 0, 0, 12, 0, 0, 0, 0, 0 },
                { 0, 12, 0, 12, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0 },
                { 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 12, 0, 0, 0 },
                { 0, 12, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 12, 0, 12, 0, 0, 0, 0 },
                { 0, 0, 12, 0, 12, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 12, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 12, 0, 12, 12, 0, 0, 0 },
                { 0, 0, 12, 0, 12, 0, 12, 0, 0, 0, 12, 0, 0, 0, 12, 0, 0, 0, 0, 0 },
                { 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0 },
                { 0, 0, 12, 0, 12, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 12, 12, 12, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 12, 0, 12, 0, 12, 0, 0, 0, 0, 0, 12, 0, 12, 0, 12, 0, 0, 0 },
                { 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
            };//GEN-END:|179-getter|1|179-midInit
            // write mid-init user code here
            for (int row = 0; row < 20; row++) {//GEN-BEGIN:|179-getter|2|179-postInit
                for (int col = 0; col < 20; col++) {
                    level1.setCell(col, row, tiles[row][col]);
                }
            }
        }//GEN-END:|179-getter|2|179-postInit
        // write post-init user code here
        return level1;//GEN-BEGIN:|179-getter|3|
    }
//GEN-END:|179-getter|3|

    public Image getPostacie_16x16() throws java.io.IOException {//GEN-BEGIN:|194-getter|0|194-preInit
        if (postacie_16x16 == null) {//GEN-END:|194-getter|0|194-preInit
            // write pre-init user code here
            postacie_16x16 = Image.createImage("/postacie 16x16.png");//GEN-BEGIN:|194-getter|1|194-postInit
        }//GEN-END:|194-getter|1|194-postInit
        // write post-init user code here
        return this.postacie_16x16;//GEN-BEGIN:|194-getter|2|
    }
//GEN-END:|194-getter|2|

    public Sprite getPlayerSprite() throws java.io.IOException {//GEN-BEGIN:|195-getter|0|195-preInit
        if (playerSprite == null) {//GEN-END:|195-getter|0|195-preInit
            // write pre-init user code here
            playerSprite = new Sprite(getPostacie_16x16(), 16, 16);//GEN-BEGIN:|195-getter|1|195-postInit
            playerSprite.setFrameSequence(walkDown);//GEN-END:|195-getter|1|195-postInit
            // write post-init user code here
        }//GEN-BEGIN:|195-getter|2|
        return playerSprite;
    }
//GEN-END:|195-getter|2|

    public Sprite getEnemy() throws java.io.IOException {//GEN-BEGIN:|200-getter|0|200-preInit
        if (enemy == null) {//GEN-END:|200-getter|0|200-preInit
            // write pre-init user code here
            enemy = new Sprite(getPostacie_16x16(), 16, 16);//GEN-BEGIN:|200-getter|1|200-postInit
            enemy.setFrameSequence(enemyseq001);//GEN-END:|200-getter|1|200-postInit
            // write post-init user code here
        }//GEN-BEGIN:|200-getter|2|
        return enemy;
    }
//GEN-END:|200-getter|2|
     public void setDynia2() throws java.io.IOException
    {
         Sprite temp;
         for(int i=0; i<bombsCount; i++)
         {
             temp = new Sprite(getBomb(), 16, 16);
             temp.setFrameSequence(bombyseq001);
             temp.setVisible(false);
             bombs.addElement(temp);
         }

    }
     public Sprite getDynia2(int i)
     {
        return (Sprite)bombs.elementAt(i);
     }


    public int setBomb(int x, int y) throws IOException
    {
        for(int i = 0; i<bombsCount; i++)
        {
            if(!getDynia2(i).isVisible())
            {
                getDynia2(i).setPosition(x, y);
                getDynia2(i).setFrameSequence(bombyseq001);
                getDynia2(i).setVisible(true);
                //i = bombsCount + 3;  //wyjscie z petli for jezeli znaleziono wolne miejsce na bombe
                return i;
            }
        }
        return -1;
  
    }

     public int findPlace(int a)
    {
        int i=0;
        while(a>0)
        {
            a = a - 16;
            i++;
        }
        

        return i;
    }

    public void boom(int i)
    {
        //getDynia2(i).setFrameSequence(boom);
        if(getDynia2(i).isVisible())
        {
            getDynia2(i).setVisible(false);
            int x = findPlace(getDynia2(i).getX()-16);
            int y = findPlace(getDynia2(i).getY()-16);

            if(y > 1)
            {
                if(level1.getCell(x, y-1) != 0)
                    level1.setCell(x, y-1, 0);
                else if(level1.getCell(x, y-2) != 0)
                    level1.setCell(x, y-2, 0);
            }
            else if(y > 0)
            {
                if(level1.getCell(x, y-1) != 0)
                    level1.setCell(x, y-1, 0);
            }

            if(y < labirynt.getRows()-1)
            {
                if(level1.getCell(x, y+1) != 0)
                    level1.setCell(x, y+1, 0);
                else if(level1.getCell(x, y+2) != 0)
                    level1.setCell(x, y+2, 0);
            }
           /* else if(y < labirynt.getRows())
            {
                if(level1.getCell(x, y+1) != 0)
                    level1.setCell(x, y+1, 0);
            }*/

            if(x > 1)
            {
                if(level1.getCell(x-1, y) != 0)
                    level1.setCell(x-1, y, 0);
                else if(level1.getCell(x-2, y) != 0)
                    level1.setCell(x-2, y, 0);
            }
            else if(x > 0)
            {
                if(level1.getCell(x-1, y) != 0)
                    level1.setCell(x-1, y, 0);
            }

            if(x < labirynt.getColumns() - 1)
            {
                if(level1.getCell(x+1, y) != 0)
                    level1.setCell(x+1, y, 0);
                else if(level1.getCell(x+2, y) != 0)
                    level1.setCell(x+2, y, 0);
            }
            else if(x < labirynt.getColumns())
            {
                if(level1.getCell(x+1, y) != 0)
                    level1.setCell(x+1, y, 0);
            }


            try
            {
                getExplosion().setPosition(getDynia2(i).getX()-32, getDynia2(i).getY()-32);
                //checkExplosion(getDynia2(i).getX()-16, getDynia2(i).getY()-16);
                getExplosion().setVisible(true);
            }
            catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    public void checkExplosion(int x, int y)
    {
        int lx = findPlace(x);
        int ly = findPlace(y);
        int lvx = findPlace(x);
        int lvy = findPlace(y);

        if(level1.getCell(lvx, lvy-2) != 0)
            explosion.setCell(0, 2, 0);

    }

    public void destroyBomb(int i)
    {
       
        try
        {
            getExplosion().setVisible(false);
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
